package com.example.administrator.myapplication;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.View;
import android.widget.AbsListView;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.alipay.sdk.app.PayResultActivity;
import com.alipay.sdk.app.PayTask;

import java.util.List;

import javax.xml.transform.Result;

public class Shouye extends Activity {
        private Button mButton1,mButton2,mButton3,mButton4,mButton5;
          private  final String orderInfo = "info";
          private Handler mHandler;

        private void SharePer(){

            SharedPreferences sharedPreferences=getSharedPreferences("access_token",0);
           String acess_token=sharedPreferences.getString("access_token",null);
           if (acess_token==null){

               Intent mIntent=new Intent(Shouye.this,MainActivity.class);
               startActivity(mIntent);

           }


        }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.shouye);
        mButton1=findViewById(R.id.btn1);
        mButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mIntent=new Intent(Shouye.this,Order.class);
                startActivity(mIntent);
            }
        });
        mButton2=findViewById(R.id.btn2);
        mButton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mIntent=new Intent(Shouye.this,StoreDetialActivity.class);
                startActivity(mIntent);
            }
        });
        mButton3=findViewById(R.id.btn3);
        mButton3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mIntent=new Intent(Shouye.this,MerchandiseControlActivity.class);
                startActivity(mIntent);
            }
        });
        mButton4=findViewById(R.id.btn4);
        mButton4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(Shouye.this,Map.class);
                startActivity(intent);

            }
            });
        mButton5=findViewById(R.id.btn5);
        mButton5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        PayTask payTask=new PayTask(Shouye.this);
                       String result= payTask.pay(orderInfo,true);
                       Message message=new Message();
                       message.obj=result;
                       message.what=1;
                       mHandler.sendMessage(message);
                    }
                }).start();
            }
        });
        mHandler=new Handler(){
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                switch (msg.what){

                }

            }
        };
        }



}
